package com.demo1224.service;

import com.demo1224.entity.User;

import java.util.HashMap;
import java.util.Map;

public class UserService {
    private static Map<Integer, User> userMap=new HashMap<>();
    static {
        userMap.put(0,new User("zhangsan","123456",0));
        userMap.put(1,new User("lisi","123456",0));
        userMap.put(2,new User("wangwu","123456",0));
        userMap.put(3,new User("zhaoliu","123456",0));
        userMap.put(4,new User("admin","123456",1));
    }

    public User login(String username,String password){
        for (int i = 0; i <userMap.size() ; i++) {
            User user = userMap.get(i);
            if (user.getName().equals(username)&&user.getPassword().equals(password)){
                return user;
            }
        }
        return null;
    }
}
